package com.maserb.monitor.dataCenter.communication;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class EigenValueRecord {
    private String pointCode;
    private SystemTime sampleTime;
    private int eigenValueCount;
    private List<EigenValue> eigenValueList;

    public static EigenValueRecord convert(byte[] content, Box<Integer> index) {
        EigenValueRecord p = new EigenValueRecord();
        Integer count = 8;
        p.pointCode = ByteUtils.getString(content, index, count);
        p.sampleTime = SystemTime.convert(content, index);
        p.eigenValueCount = ByteUtils.getInt(content, index);
        p.eigenValueList = new ArrayList<EigenValue>();
        for (int i = 0; i < p.eigenValueCount; i++) {
            EigenValue eigenValue = EigenValue.convert(content, index);
            p.eigenValueList.add(eigenValue);
        }

        return p;
    }
}
